package com.quick.controller;

import com.quick.domain.Book;
import com.quick.service.BookService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName BookController
 * @Description TODO
 * @Author wangxin332
 * @Date 2018/10/8 下午3:52
 * @Version 1.0
 **/
@RestController
@RequestMapping("/test")
@Slf4j
public class BookController {
	@Resource
	private BookService bookService;

	@RequestMapping("/test")
	public String testInsert(String bookName,String isbn,String author){
		log.info("bookName:{},isbn:{},author:{}",bookName,isbn,author);
		Book book = new Book();
		book.setBookName(bookName);
		book.setIsbn(isbn);
		book.setAuthor(author);
		try {
			bookService.insert(book);
		}catch (Exception e){
			return "error";
		}
		return "success";
	}

	@RequestMapping("/query")
	public Book query(String isbn){
		return bookService.query(isbn);
	}
}
